﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PaymentHelper.Core.MultiLanguage
{
    public class LanguagePackage
    {
        public string Code { get; set; }
        public Dictionary<string, string> LanguageResources { get; set; }
        public bool IsDefault { get; set; }

        public string this[string id]
        {
            get
            {
                return GetLanguageResource(id);
            }
            set
            {
                AddLanguageResource(id, value);
            }
        }

        public string GetLanguageResource(string key)
        {
            key = key.ToLower();

            if (LanguageResources.Keys.Contains(key) == false)
                return "";
            return LanguageResources[key];
        }

        public void AddLanguageResource(string key, string value, bool replaceIfExist = true)
        {
            key = key.ToLower();

            if (LanguageResources.Keys.Contains(key) == false)
                LanguageResources.Add(key, value);
            else
            {
                if (replaceIfExist)
                    LanguageResources[key] = value;
            }
        }

        public int GetNumResources()
        {
            return LanguageResources.Count;
        }

    }
}
